var selectedRow = '';

$(function () {
    // var curDate = new Date();
    // var preDate = new Date(curDate.getTime() - 24*60*60*1000); //前一天
    laydate.render({
        elem: '#gmtCreateStr'
        ,type: 'datetime'
        ,range: true //或 range: '~' 来自定义分割字符
        // ,value: dateFtt("yyyy-MM-dd hh:mm:ss", preDate) + ' - ' + dateFtt("yyyy-MM-dd hh:mm:ss", curDate)
        //js赋值重置失效，改为就是怕、页面赋值
        ,isInitValue: true //是否允许填充初始值，默认为 true
    });
    doRefresh();
});

function doRefresh() {
    var gmtStart = '';
    var gmtEnd = '';
    var gmtCreateStr = $("#gmtCreateStr").val();
    if(gmtCreateStr){
        var dates = gmtCreateStr.split(' - ');
        if(dates && dates.length >1){
            gmtStart = dates[0];
            gmtEnd = dates[1];
        }
    }
    if(!gmtStart || !gmtEnd){
        toastr.error('请选择一个时间段后重试');
        return;
    }
    selectedRow = '';
    var content = $('#content').val();
    var className = $('#className').val();
    var methodName = $('#methodName').val();
    var url = $('#url').val();
    var clientIp = $('#clientIp').val();
    var operator = $('#operator').val();
    $('#dataTable').bootstrapTable('refresh', {
        url: basePath + 'pfLog/pageFindPfLogData?t=' + new Date().getTime(),
        query: {
            content : content,
            className : className,
            methodName : methodName,
            url : url,
            gmtStart : gmtStart,
            gmtEnd : gmtEnd,
            clientIp : clientIp,
            operator : operator
        },
    });
}

function getParams(params) {
    var content = $('#content').val();
    var className = $('#className').val();
    var methodName = $('#methodName').val();
    var url = $('#url').val();
    var clientIp = $('#clientIp').val();
    var operator = $('#operator').val();
    return {
        content : content,
        className : className,
        methodName : methodName,
        url : url,
        clientIp : clientIp,
        operator : operator,
        pageSize : params.pageSize,
        pageNo : params.pageNumber
    };
}

function openInfoPage() {
    if (!selectedRow.id || selectedRow.id == '') {
        toastr.error(common_no_choose_msg.format("操作"));
        return;
    }
    window.location.href = basePath + 'pfLog/openPfLogPage?&id=' + selectedRow.id +
        '&type=info&t=' + new Date().getTime();
}

$("#dataTable").on("click-row.bs.table",function(e,row,ele){
    $("#dataTable .success").removeClass("success");
    $(ele).addClass("success");
    selectedRow = row;
});